package cn.edu.sjtu.software.sjtucontacts.util;

import java.util.Vector;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.edu.sjtu.software.sjtucontacts.R;

public class ExpBaseAdapter extends BaseAdapter {
	private Context mContext;
	private Vector mItems = new Vector();
	private LinearLayout layout, layout_more;

	public ExpBaseAdapter(Context context) {
		mContext = context;
	}

	public void addItem(FileData it) {
		mItems.add(it);
	}

	public FileData getItem(int it) {
		return (FileData) mItems.elementAt(it);
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return mItems.size();
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	public int getItemType(int arg0) {
		// TODO Auto-generated method stub
		return getItem(arg0).type;
	}

	public void clearItems() {
		mItems.clear();
	}

	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		// LinearLayout layout=null ;
		if(((FileData)mItems.get(arg0)).type==1){
			LayoutInflater inflate = (LayoutInflater) mContext
				.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
			arg1 = (LinearLayout) inflate.inflate(R.layout.listfile, null);
			TextView fm_text_01 = (TextView) arg1.findViewById(R.id.fm_text_01);
			fm_text_01.setText(getItem(arg0).name);
		}else{
			LayoutInflater inflate = (LayoutInflater) mContext
				.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
			arg1 = (LinearLayout) inflate.inflate(R.layout.listfiles, null);
			TextView fm_text_00 = (TextView) arg1.findViewById(R.id.fm_text_00);
			fm_text_00.setText(getItem(arg0).name);	
		}
		
		// Log.v("vodone",""+arg0+" name="+getItem(arg0).name);
		/*
		 * if (getItem(arg0).equals(".")){ }
		 */
		return arg1;
	}
}
